﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RearLivestock.Beginning.Api.Application.Command.Infancie;
using RearLivestock.Common.Dtos;
using Yitter.IdGenerator;

namespace RearLivestock.Beginning.Api.Controllers
{
    /// <summary>
    /// 公猪期初控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InfanciesController : ControllerBase
    {
        private readonly IMediator mediator;

        public InfanciesController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 公猪期初添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> AddInfancies(AddInfanciesCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 猪只信息列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> GetBasicInformation(GetBasicInformationCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 栋舍信息列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> GetBedrooms(GetedroomTypeCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 公猪期初信息列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<PageResultDto<InfanciesDto>>> ShowInfancies(QueryInfanciesCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 公猪期初信息删除
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<Result> DelInfancies(DelInfanciesCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
